package hardcode2013;

public class EncodeUtil {
	public static String encodeHtml(String input) {
		return input.replaceAll("\\&", "&amp;")
		         .replaceAll("\\<", "&lt;")
		         .replaceAll("\\>", "&gt;")
		         .replaceAll("\\\"", "&quot;")
		         .replaceAll("\\\'", "&#039;");
	}
	
	public static String encodeUrl(String input) {
		return input.replaceAll("\\%", "%25")
				 .replaceAll("\\:", "%3B")
		         .replaceAll("\\/", "%2F")
		         .replaceAll("\\#", "%23")
		         .replaceAll("\\?", "%3F")
		         .replaceAll("\\&", "%24")
		         .replaceAll("\\@", "%40")
		         .replaceAll("\\+", "%2B")
		         .replaceAll("\\~", "%&E");
	}
}
